<meta title="广告选择器" args="multi:true" width="800"/>
<div class="p">
    <div class="m-b clearfix">
        <form class="form-inline pull-left" id="form">
            <input autocomplete="off" type="text" class="form-control input-sm" placeholder="广告名" style="width:200px;" name="name" />
            <input autocomplete="off" type="hidden" name="page" id="page" value="1"/>
            <select class="form-control input-sm" s="select" name="valid">
                <option value="">所有状态</option>
                <option value="true">正常</option>
                <option value="false">锁定</option>
            </select>
            <button type="button" class="btn btn-default btn-sm" s-click="$page.node.val(1); $advsGrid.refresh()">查询</button>
        </form>
    </div>
    <div id="advsGrid"
         s='datac,nda,check'
         s-check="{multiple: multi}"
         s-data="S.get('/api/adv/search', $form.node.serialize())">
        <table class="table table-striped table-bordered table-hover table-middle">
            <tr>
                <th>
                    <label class="s-checkbox">
                        <input autocomplete="off" type="checkbox" s-check-role="checkall-h"/>
                        <span class="s-checkbox-indicator"></span>
                    </label>
                </th>
                <th>图片</th>
                <th>名称</th>
                <th>创建时间</th>
                <th>开始时间</th>
                <th>结束时间</th>
                <th>状态</th>
                <th class="text-right">操作</th>
            </tr>
            <tbody s="loop" s-data-filter="'results'">
            <tr s-loop-role="empty">
                <td colspan="9">暂无数据</td>
            </tr>
            <tr s-loop-role="row" s-check-role="i" s="datac" class="adv">
                <td>
                    <label class="s-checkbox">
                        <input autocomplete="off" type="checkbox" s-check-role="h" />
                        <span class="s-checkbox-indicator"></span>
                    </label>
                </td>
                <td s="tpl">
                    <a href="{%=this.picUrl%}" external target="_blank">
                        <img src="{%=this.picUrl%}" style="max-width: 100px; max-height: 100px;" />
                    </a>
                </td>
                <td name="name"></td>
                <td name="createTime"></td>
                <td name="startTime"></td>
                <td name="endTime"></td>
                <td s="tpl">
                    {%if(this.valid){%}
                    <label class="label label-success">正常</label>
                    {%}else{%}
                    <label class="label label-default">锁定</label>
                    {%}%}
                </td>
                <td class="text-right">
                    <input autocomplete="off" type="button" class="btn btn-primary btn-outline btn-xs" s-click="edit(this)" value="编辑" />
                    <input autocomplete="off" type="button" class="btn btn-danger btn-outline btn-xs" s-click="del(this)" value="删除" />
                </td>
            </tr>
            </tbody>
            <tfoot>
            <tr>
                <td colspan="9" class="text-right">
                    共有<span name="total"></span>个数据
                    <ul s="pagination"
                        s-pagination="{action:function(){$page.node.val(this); $advsGrid.refresh()}}"
                        class="pagination pagination-sm">
                    </ul>
                </td>
            </tr>
            </tfoot>
        </table>
    </div>
</div>
<script type="text/javascript">

    S.meta.btns = [
        {
            name: "选择",
            style: "btn btn-primary",
            click: function() {
                var datas = $advsGrid.getCheckedData();
                if (datas.length) {
                    S.close(datas);
                } else {
                    S.toast("您还没有选择广告！", "warning");
                }
            }
        },
        {
            name: "关闭",
            style: "btn btn-default",
            click: function() {
                S.close();
            }
        }
    ]

</script>